package com.zxy.service.impl;

import com.zxy.mapper.AccountMapper;
import com.zxy.service.AccountService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.concurrent.TimeUnit;

/**
 * @author: Zxy
 * @description:
 * @date: 2021-08-21 14:13
 */
@Service
@Slf4j
public class AccountServiceImpl implements AccountService {

    @Resource
    private AccountMapper accountMapper;

    @Override
    public void decrease(Long userId, BigDecimal count) {
        try {
            TimeUnit.SECONDS.sleep(20);
        } catch (InterruptedException e) {
            log.info("----->account error!!!");
            e.printStackTrace();
        }
        accountMapper.decrease(userId, count);
    }

}
